{extend name="layout"}
{block name="detail"}

<section class="forms">
    <div class="container-fluid">
        <div class="row">
            <!-- Form Elements -->
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header d-flex align-items-center">
                        <h3 class="h4">修改商品</h3>
                    </div>
                    <div class="card-body">
                        <form class="form-horizontal" method="post" action="{:url('admin/product/saveProduct')}" enctype="multipart/form-data" id="pFrom">
                            <input type="hidden" name="shopId" value="{$shop.id}">
                            <input type="hidden" name="id" value="{$product.id}">
                            <div class="form-group row">
                                <label for="title" class="col-sm-2 form-control-label">商品标题</label>
                                <div class="col-sm-9">
                                    <input id="title" type="text" required name="title" value="{$product.title}"  class="form-control">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="img" class="col-sm-2 form-control-label">请上传产品图片</label>
                                <div class="col-sm-9">
                                    <img src="{$product.img}" alt="" width="50" class="bdimg">
                                    <input id="img" type="file"  name="img" accept="image/*" multiple >
                                </div>
                            </div>
                            <div class="form-group row">
                                <label  class="col-sm-2 form-control-label">是否上架</label>
                                <div class="col-sm-9">
                                    <input  type="radio" required name="isShow"  value="1" {if condition="$product['isShow'] eq 1"}checked{/if}>是
                                    <input  type="radio" required name="isShow" value="0" {if condition="$product['isShow'] eq 0"}checked{/if}>否
                                </div>
                            </div>

                            <div class="form-group row">
                                <label  class="col-sm-2 form-control-label">商品详情</label>
                                <div class="col-sm-9">
                                    <script id="container" name="info" type="text/plain">{$product.info}</script>
                                </div>
                            </div>
                            <p style="line-height: 40px">*系统建议代理利润不低于{$min_profit}%</p>
                            {for start="1" end="10"}
                            {if condition="isset($guige[$i-1])"}
                                <div class="form-group row">
                                    <div class="col-sm-2"></div>
                                    <div class="col-sm-3">
                                        商品规格： <input id="guige[]" type="text"  name="guige[]" value="{$guige[$i-1]['guige']}"  class="form-control">
                                    </div>

                                    <div class="col-sm-3">
                                        商品卖价 <input id="salePrice[]" type="text"  name="salePrice[]" value="{$guige[$i-1]['salePrice']}" class="form-control">
                                    </div>

                                    <div class="col-sm-3">
                                        商品代理价<input id="agentPrice[]" type="text"  name="agentPrice[]" value="{$guige[$i-1]['agentPrice']}" class="form-control agentPrice">
                                    </div>
                                </div>
                            {else}
                                <div class="form-group row">
                                    <div class="col-sm-2"></div>
                                    <div class="col-sm-3">
                                        商品规格： <input id="guige[]" type="text"  name="guige[]"   class="form-control">
                                    </div>

                                    <div class="col-sm-3">
                                        商品卖价 <input id="salePrice[]" type="text"  name="salePrice[]"  class="form-control">
                                    </div>

                                    <div class="col-sm-3">
                                        商品代理价<input id="agentPrice[]" type="text"  name="agentPrice[]"  class="form-control agentPrice">
                                    </div>
                                </div>
                            {/if}
                            {/for}

                            <div class="form-group row">
                                <div class="col-sm-4 offset-sm-3">
                                    <button type="submit" class="btn btn-primary">保存</button>
                                    <button type="reset" class="btn btn-secondary">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container',{
        toolbars: [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
            'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
            'print', 'preview', 'searchreplace', 'drafts', 'help'
        ]],
        autoHeightEnabled: true,
        autoFloatEnabled: true,
        allowDivTransToP: false,
        initialFrameHeight:550,
    });
</script>
{/block}